<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class OpenSSL::X509::Name - openssl: Ruby Standard Library Documentation</title>


<script src="../../js/navigation.js" defer></script>
<script src="../../js/search.js" defer></script>
<script src="../../js/search_index.js" defer></script>
<script src="../../js/searcher.js" defer></script>
<script src="../../js/darkfish.js" defer></script>

<script src="../../js/jquery-3.2.0.min.js"></script>

<script src="../../js/vue.min.js"></script>
<script src="../../js/js.cookie.min.js"></script>

<link href="../../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../../css/rdoc.css" rel="stylesheet">
<link href="../../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../../";
  var index_rel_prefix = "../../";
  var darkModeCsseHref = "../../css/rdoc-dm.css"
  var defaultModeCssHref = "../../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../../table_of_contents.html#pages">Pages</a>
    <a href="../../table_of_contents.html#classes">Classes</a>
    <a href="../../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Object
</div>

        
<div id="includes-section" class="nav-section">
  <h3>Included Modules</h3>

  <ul class="link-list">
    <li><a class="include" href="../Marshal.html">OpenSSL::Marshal</a>
    <li><span class="include">Comparable</span>
  </ul>
</div>

        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-c-parse">::parse</a>
    <li ><a href="#method-c-parse_openssl">::parse_openssl</a>
    <li ><a href="#method-c-parse_rfc2253">::parse_rfc2253</a>
    <li ><a href="#method-i-3C-3D-3E">#&lt;=&gt;</a>
    <li ><a href="#method-i-add_entry">#add_entry</a>
    <li ><a href="#method-i-cmp">#cmp</a>
    <li ><a href="#method-i-eql-3F">#eql?</a>
    <li ><a href="#method-i-hash">#hash</a>
    <li ><a href="#method-i-hash_old">#hash_old</a>
    <li ><a href="#method-i-initialize_copy">#initialize_copy</a>
    <li ><a href="#method-i-pretty_print">#pretty_print</a>
    <li ><a href="#method-i-to_a">#to_a</a>
    <li ><a href="#method-i-to_der">#to_der</a>
    <li ><a href="#method-i-to_s">#to_s</a>
    <li ><a href="#method-i-to_utf8">#to_utf8</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-OpenSSL::X509::Name">
    <h1 id="class-OpenSSL::X509::Name" class="class">
      class OpenSSL::X509::Name
    </h1>

    <section class="description">
    
<p>An X.509 name represents a hostname, email address or other entity associated with a public key.</p>

<p>You can create a <a href="Name.html"><code>Name</code></a> by parsing a distinguished name String or by supplying the distinguished name as an Array.</p>

<pre class="ruby"><span class="ruby-identifier">name</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">X509</span><span class="ruby-operator">::</span><span class="ruby-constant">Name</span>.<span class="ruby-identifier">parse_rfc2253</span> <span class="ruby-string">&#39;DC=example,CN=nobody&#39;</span>

<span class="ruby-identifier">name</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">X509</span><span class="ruby-operator">::</span><span class="ruby-constant">Name</span>.<span class="ruby-identifier">new</span> [[<span class="ruby-string">&#39;CN&#39;</span>, <span class="ruby-string">&#39;nobody&#39;</span>], [<span class="ruby-string">&#39;DC&#39;</span>, <span class="ruby-string">&#39;example&#39;</span>]]
</pre>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="COMPAT">COMPAT
          <dd><p>A flag for <a href="Name.html#method-i-to_s"><code>to_s</code></a>.</p>

<p>Breaks the name returned into multiple lines if longer than 80 characters.</p>
          <dt id="DEFAULT_OBJECT_TYPE">DEFAULT_OBJECT_TYPE
          <dd><p>The default object type for name entries.</p>
          <dt id="MULTILINE">MULTILINE
          <dd><p>A flag for <a href="Name.html#method-i-to_s"><code>to_s</code></a>.</p>

<p>Returns a multiline format.</p>
          <dt id="OBJECT_TYPE_TEMPLATE">OBJECT_TYPE_TEMPLATE
          <dd><p>The default object type template for name entries.</p>
          <dt id="ONELINE">ONELINE
          <dd><p>A flag for <a href="Name.html#method-i-to_s"><code>to_s</code></a>.</p>

<p>Returns a more readable format than <a href="Name.html#RFC2253"><code>RFC2253</code></a>.</p>
          <dt id="RFC2253">RFC2253
          <dd><p>A flag for <a href="Name.html#method-i-to_s"><code>to_s</code></a>.</p>

<p>Returns an <a href="Name.html#RFC2253"><code>RFC2253</code></a> format name.</p>
        </dl>
        </section>



                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-new" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          X509::Name.new                               &rarr; name
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          X509::Name.new(der)                          &rarr; name
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          X509::Name.new(distinguished_name)           &rarr; name
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          X509::Name.new(distinguished_name, template) &rarr; name
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Creates a new <a href="Name.html"><code>Name</code></a>.</p>

<p>A name may be created from a DER encoded string <em>der</em>, an Array representing a <em>distinguished_name</em> or a <em>distinguished_name</em> along with a <em>template</em>.</p>

<pre class="ruby"><span class="ruby-identifier">name</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">X509</span><span class="ruby-operator">::</span><span class="ruby-constant">Name</span>.<span class="ruby-identifier">new</span> [[<span class="ruby-string">&#39;CN&#39;</span>, <span class="ruby-string">&#39;nobody&#39;</span>], [<span class="ruby-string">&#39;DC&#39;</span>, <span class="ruby-string">&#39;example&#39;</span>]]

<span class="ruby-identifier">name</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">X509</span><span class="ruby-operator">::</span><span class="ruby-constant">Name</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_der</span>
</pre>

<p>See <a href="Name.html#method-i-add_entry"><code>add_entry</code></a> for a description of the <em>distinguished_name</em> Array’s contents</p>

                              <div class="method-source-code" id="new-source">
            <pre>static VALUE
ossl_x509name_initialize(int argc, VALUE *argv, VALUE self)
{
    X509_NAME *name;
    VALUE arg, template;

    GetX509Name(self, name);
    if (rb_scan_args(argc, argv, &quot;02&quot;, &amp;arg, &amp;template) == 0) {
        return self;
    }
    else {
        VALUE tmp = rb_check_array_type(arg);
        if (!NIL_P(tmp)) {
            VALUE args;
            if(NIL_P(template)) template = OBJECT_TYPE_TEMPLATE;
            args = rb_ary_new3(2, self, template);
            rb_block_call(tmp, rb_intern(&quot;each&quot;), 0, 0, ossl_x509name_init_i, args);
        }
        else{
            const unsigned char *p;
            VALUE str = ossl_to_der_if_possible(arg);
            X509_NAME *x;
            StringValue(str);
            p = (unsigned char *)RSTRING_PTR(str);
            x = d2i_X509_NAME(&amp;name, &amp;p, RSTRING_LEN(str));
            DATA_PTR(self) = name;
            if(!x){
                ossl_raise(eX509NameError, NULL);
            }
        }
    }

    return self;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-parse" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">parse</span><span
                                class="method-args">(str, template=OBJECT_TYPE_TEMPLATE)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Name.html#method-c-parse_openssl">parse_openssl</a>
                            </div>
                          </div>

                  <div id="method-c-parse_openssl" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">parse_openssl</span><span
                                class="method-args">(str, template=OBJECT_TYPE_TEMPLATE)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Parses the string representation of a distinguished name. Two different forms are supported:</p>
<ul><li>
<p>OpenSSL format (<code>X509_NAME_oneline()</code>) used by <code>#to_s</code>. For example: <code>/DC=com/DC=example/CN=nobody</code></p>
</li><li>
<p>OpenSSL format (<code>X509_NAME_print()</code>) used by <code>#to_s(OpenSSL::X509::Name::COMPAT)</code>. For example: <code>DC=com, DC=example, CN=nobody</code></p>
</li></ul>

<p>Neither of them is standardized and has quirks and inconsistencies in handling of escaped characters or multi-valued RDNs.</p>

<p>Use of this method is discouraged in new applications. See <a href="Name.html#method-c-parse_rfc2253"><code>Name.parse_rfc2253</code></a> and <a href="Name.html#method-i-to_utf8"><code>to_utf8</code></a> for the alternative.</p>

                              <div class="method-source-code" id="parse_openssl-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/x509.rb, line 305</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">parse_openssl</span>(<span class="ruby-identifier">str</span>, <span class="ruby-identifier">template</span>=<span class="ruby-constant">OBJECT_TYPE_TEMPLATE</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">str</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&quot;/&quot;</span>)
    <span class="ruby-comment"># /A=B/C=D format</span>
    <span class="ruby-identifier">ary</span> = <span class="ruby-identifier">str</span>[<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>].<span class="ruby-identifier">split</span>(<span class="ruby-string">&quot;/&quot;</span>).<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">i</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">&quot;=&quot;</span>, <span class="ruby-value">2</span>) }
  <span class="ruby-keyword">else</span>
    <span class="ruby-comment"># Comma-separated</span>
    <span class="ruby-identifier">ary</span> = <span class="ruby-identifier">str</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">&quot;,&quot;</span>).<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">i</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">&quot;=&quot;</span>, <span class="ruby-value">2</span>) }
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ary</span>, <span class="ruby-identifier">template</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Name.html#method-c-parse">parse</a>
                            </div>

                          </div>

                  <div id="method-c-parse_rfc2253" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">parse_rfc2253</span><span
                                class="method-args">(str, template=OBJECT_TYPE_TEMPLATE)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Parses the UTF-8 string representation of a distinguished name, according to RFC 2253.</p>

<p>See also <a href="Name.html#method-i-to_utf8"><code>to_utf8</code></a> for the opposite operation.</p>

                              <div class="method-source-code" id="parse_rfc2253-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/x509.rb, line 286</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">parse_rfc2253</span>(<span class="ruby-identifier">str</span>, <span class="ruby-identifier">template</span>=<span class="ruby-constant">OBJECT_TYPE_TEMPLATE</span>)
  <span class="ruby-identifier">ary</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">X509</span><span class="ruby-operator">::</span><span class="ruby-constant">Name</span><span class="ruby-operator">::</span><span class="ruby-constant">RFC2253DN</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-identifier">str</span>)
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ary</span>, <span class="ruby-identifier">template</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-3C-3D-3E" class="method-detail method-alias">
                      <div class="method-heading">
                        <span class="method-callseq">
                          name &lt;=&gt; other  &rarr; -1 | 0 | 1 | nil
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Compares this <a href="Name.html"><code>Name</code></a> with <em>other</em> and returns <code>0</code> if they are the same and <code>-1</code> or <code>+1</code> if they are greater or less than each other respectively. Returns <code>nil</code> if they are not comparable (i.e. different types).</p>

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Name.html#method-i-cmp">cmp</a>
                            </div>
                          </div>

                  <div id="method-i-add_entry" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          add_entry(oid, value [, type], loc: -1, set: 0) &rarr; self
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Adds a new entry with the given <em>oid</em> and <em>value</em> to this name.  The <em>oid</em> is an object identifier defined in ASN.1.  Some common OIDs are:</p>
<dl class="rdoc-list note-list"><dt>C
<dd>
<p>Country <a href="Name.html"><code>Name</code></a></p>
</dd><dt>CN
<dd>
<p>Common <a href="Name.html"><code>Name</code></a></p>
</dd><dt>DC
<dd>
<p>Domain Component</p>
</dd><dt>O
<dd>
<p>Organization <a href="Name.html"><code>Name</code></a></p>
</dd><dt>OU
<dd>
<p>Organizational Unit <a href="Name.html"><code>Name</code></a></p>
</dd><dt>ST
<dd>
<p>State or Province <a href="Name.html"><code>Name</code></a></p>
</dd></dl>

<p>The optional keyword parameters <em>loc</em> and <em>set</em> specify where to insert the new attribute. Refer to the manpage of X509_NAME_add_entry(3) for details. <em>loc</em> defaults to -1 and <em>set</em> defaults to 0. This appends a single-valued RDN to the end.</p>

                              <div class="method-source-code" id="add_entry-source">
            <pre>static
VALUE ossl_x509name_add_entry(int argc, VALUE *argv, VALUE self)
{
    X509_NAME *name;
    VALUE oid, value, type, opts, kwargs[2];
    static ID kwargs_ids[2];
    const char *oid_name;
    int loc = -1, set = 0;

    if (!kwargs_ids[0]) {
        kwargs_ids[0] = rb_intern_const(&quot;loc&quot;);
        kwargs_ids[1] = rb_intern_const(&quot;set&quot;);
    }
    rb_scan_args(argc, argv, &quot;21:&quot;, &amp;oid, &amp;value, &amp;type, &amp;opts);
    rb_get_kwargs(opts, kwargs_ids, 0, 2, kwargs);
    oid_name = StringValueCStr(oid);
    StringValue(value);
    if(NIL_P(type)) type = rb_aref(OBJECT_TYPE_TEMPLATE, oid);
    if (kwargs[0] != Qundef)
        loc = NUM2INT(kwargs[0]);
    if (kwargs[1] != Qundef)
        set = NUM2INT(kwargs[1]);
    GetX509Name(self, name);
    if (!X509_NAME_add_entry_by_txt(name, oid_name, NUM2INT(type),
                                    (unsigned char *)RSTRING_PTR(value),
                                    RSTRING_LENINT(value), loc, set))
        ossl_raise(eX509NameError, &quot;X509_NAME_add_entry_by_txt&quot;);
    return self;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-cmp" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          cmp(other) &rarr; -1 | 0 | 1 | nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Compares this <a href="Name.html"><code>Name</code></a> with <em>other</em> and returns <code>0</code> if they are the same and <code>-1</code> or <code>+1</code> if they are greater or less than each other respectively. Returns <code>nil</code> if they are not comparable (i.e. different types).</p>

                              <div class="method-source-code" id="cmp-source">
            <pre>static VALUE
ossl_x509name_cmp(VALUE self, VALUE other)
{
    int result;

    if (!rb_obj_is_kind_of(other, cX509Name))
        return Qnil;

    result = ossl_x509name_cmp0(self, other);
    if (result &lt; 0) return INT2FIX(-1);
    if (result &gt; 0) return INT2FIX(1);

    return INT2FIX(0);
}</pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Name.html#method-i-3C-3D-3E">&lt;=&gt;</a>
                            </div>

                          </div>

                  <div id="method-i-eql-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          eql?(other) &rarr; true | false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns true if <em>name</em> and <em>other</em> refer to the same hash key.</p>

                              <div class="method-source-code" id="eql-3F-source">
            <pre>static VALUE
ossl_x509name_eql(VALUE self, VALUE other)
{
    if (!rb_obj_is_kind_of(other, cX509Name))
        return Qfalse;

    return ossl_x509name_cmp0(self, other) == 0 ? Qtrue : Qfalse;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-hash" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          hash &rarr; integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>The hash value returned is suitable for use as a certificate’s filename in a CA path.</p>

                              <div class="method-source-code" id="hash-source">
            <pre>static VALUE
ossl_x509name_hash(VALUE self)
{
    X509_NAME *name;
    unsigned long hash;

    GetX509Name(self, name);

    hash = X509_NAME_hash(name);

    return ULONG2NUM(hash);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-hash_old" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          hash_old &rarr; integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an MD5 based hash used in <a href="../../OpenSSL.html"><code>OpenSSL</code></a> 0.9.X.</p>

                              <div class="method-source-code" id="hash_old-source">
            <pre>static VALUE
ossl_x509name_hash_old(VALUE self)
{
    X509_NAME *name;
    unsigned long hash;

    GetX509Name(self, name);

    hash = X509_NAME_hash_old(name);

    return ULONG2NUM(hash);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-initialize_copy" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">initialize_copy</span><span
                                class="method-args">(p1)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="initialize_copy-source">
            <pre>static VALUE
ossl_x509name_initialize_copy(VALUE self, VALUE other)
{
    X509_NAME *name, *name_other, *name_new;

    rb_check_frozen(self);
    GetX509Name(self, name);
    GetX509Name(other, name_other);

    name_new = X509_NAME_dup(name_other);
    if (!name_new)
        ossl_raise(eX509NameError, &quot;X509_NAME_dup&quot;);

    SetX509Name(self, name_new);
    X509_NAME_free(name);

    return self;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-pretty_print" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">pretty_print</span><span
                                class="method-args">(q)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="pretty_print-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/x509.rb, line 319</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">pretty_print</span>(<span class="ruby-identifier">q</span>)
  <span class="ruby-identifier">q</span>.<span class="ruby-identifier">object_group</span>(<span class="ruby-keyword">self</span>) {
    <span class="ruby-identifier">q</span>.<span class="ruby-identifier">text</span> <span class="ruby-string">&#39; &#39;</span>
    <span class="ruby-identifier">q</span>.<span class="ruby-identifier">text</span> <span class="ruby-identifier">to_s</span>(<span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">X509</span><span class="ruby-operator">::</span><span class="ruby-constant">Name</span><span class="ruby-operator">::</span><span class="ruby-constant">RFC2253</span>)
  }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_a" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_a &rarr; [[name, data, type], ...]
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an Array representation of the distinguished name suitable for passing to <a href="Name.html#method-c-new"><code>::new</code></a></p>

                              <div class="method-source-code" id="to_a-source">
            <pre>static VALUE
ossl_x509name_to_a(VALUE self)
{
    X509_NAME *name;
    X509_NAME_ENTRY *entry;
    int i,entries,nid;
    char long_name[512];
    const char *short_name;
    VALUE ary, vname, ret;
    ASN1_STRING *value;

    GetX509Name(self, name);
    entries = X509_NAME_entry_count(name);
    if (entries &lt; 0) {
        OSSL_Debug(&quot;name entries &lt; 0!&quot;);
        return rb_ary_new();
    }
    ret = rb_ary_new2(entries);
    for (i=0; i&lt;entries; i++) {
        if (!(entry = X509_NAME_get_entry(name, i))) {
            ossl_raise(eX509NameError, NULL);
        }
        if (!i2t_ASN1_OBJECT(long_name, sizeof(long_name),
                             X509_NAME_ENTRY_get_object(entry))) {
            ossl_raise(eX509NameError, NULL);
        }
        nid = OBJ_ln2nid(long_name);
        if (nid == NID_undef) {
            vname = rb_str_new2((const char *) &amp;long_name);
        } else {
            short_name = OBJ_nid2sn(nid);
            vname = rb_str_new2(short_name); /*do not free*/
        }
        value = X509_NAME_ENTRY_get_data(entry);
        ary = rb_ary_new3(3, vname, asn1str_to_str(value), INT2NUM(value-&gt;type));
        rb_ary_push(ret, ary);
    }
    return ret;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_der" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_der &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Converts the name to DER encoding</p>

                              <div class="method-source-code" id="to_der-source">
            <pre>static VALUE
ossl_x509name_to_der(VALUE self)
{
    X509_NAME *name;
    VALUE str;
    long len;
    unsigned char *p;

    GetX509Name(self, name);
    if((len = i2d_X509_NAME(name, NULL)) &lt;= 0)
        ossl_raise(eX509NameError, NULL);
    str = rb_str_new(0, len);
    p = (unsigned char *)RSTRING_PTR(str);
    if(i2d_X509_NAME(name, &amp;p) &lt;= 0)
        ossl_raise(eX509NameError, NULL);
    ossl_str_adjust(str, p);

    return str;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_s" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_s         &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_s(format) &rarr; string
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns a String representation of the Distinguished <a href="Name.html"><code>Name</code></a>. <em>format</em> is one of:</p>
<ul><li>
<p><a href="Name.html#COMPAT"><code>OpenSSL::X509::Name::COMPAT</code></a></p>
</li><li>
<p><a href="Name.html#RFC2253"><code>OpenSSL::X509::Name::RFC2253</code></a></p>
</li><li>
<p><a href="Name.html#ONELINE"><code>OpenSSL::X509::Name::ONELINE</code></a></p>
</li><li>
<p><a href="Name.html#MULTILINE"><code>OpenSSL::X509::Name::MULTILINE</code></a></p>
</li></ul>

<p>If <em>format</em> is omitted, the largely broken and traditional <a href="../../OpenSSL.html"><code>OpenSSL</code></a> format (<code>X509_NAME_oneline()</code> format) is chosen.</p>

<p><strong>Use of this method is discouraged.</strong> None of the formats other than <a href="Name.html#RFC2253"><code>OpenSSL::X509::Name::RFC2253</code></a> is standardized and may show an inconsistent behavior through OpenSSL versions.</p>

<p>It is recommended to use <a href="Name.html#method-i-to_utf8"><code>to_utf8</code></a> instead, which is equivalent to calling <code>name.to_s(OpenSSL::X509::Name::RFC2253).force_encoding(&quot;UTF-8&quot;)</code>.</p>

                              <div class="method-source-code" id="to_s-source">
            <pre>static VALUE
ossl_x509name_to_s(int argc, VALUE *argv, VALUE self)
{
    rb_check_arity(argc, 0, 1);
    /* name.to_s(nil) was allowed */
    if (!argc || NIL_P(argv[0]))
        return ossl_x509name_to_s_old(self);
    else
        return x509name_print(self, NUM2ULONG(argv[0]));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_utf8" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_utf8 &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an UTF-8 representation of the distinguished name, as specified in <a href="https://www.ietf.org/rfc/rfc2253.txt">RFC 2253</a>.</p>

                              <div class="method-source-code" id="to_utf8-source">
            <pre>static VALUE
ossl_x509name_to_utf8(VALUE self)
{
    VALUE str = x509name_print(self, XN_FLAG_RFC2253 &amp; ~ASN1_STRFLGS_ESC_MSB);
    rb_enc_associate_index(str, rb_utf8_encindex());
    return str;
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>.</p><p><a href="https://jamesbritt.bandcamp.com/">Maximum R+D</a>.  </p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

